function myonfocus(id) {
  var mobileNo = $("#" + id).val();
  if (mobileNo == '请输入登录使用的帐号') {
      document.getElementById(id).value = "";
  }
  document.getElementById(id).className = "dzyx_k dzyx_k_hs";
}


function myonblur(id) {
  var mobileNo = $("#" + id).val();
  if (mobileNo == '') {
      document.getElementById(id).className = "dzyx_k";
      document.getElementById(id).value = "请输入登录使用的帐号";
  }
}





var iscode_2 = 0;

function process(flag) {
  String.prototype.PWD = function () {if (/^(\w{6})|(\w{15})$/.test(this)) return true; else return false;}
  var pwdtype = $("input[name=pwdtype]:checked").val()
  var phone1 = $("#v_phone1").val();
  var code = $("#v_code").val();
  var pwd = $("#v_pwd").val();
  var pwd1 = $("#v_pwd1").val();


  var index =0;
  if (flag == 0) {
       $('.doc_password').hide().eq(1).show();
       return false;
  }
  if(flag == 1){
       if (phone1 == "") {
          $("#phone_msg").html("请输入完整手机号码！");
          $("#v_phone1").focus();
          return;
      } else {
          $("#phone_msg").html("");
      }
      index=2;
  }
  if(flag==2){
      if (code == "") {
          $("#code_msg").html("输入验证码！");
          $("#v_code").focus();
          return;
      } else {
          $("#code_msg").html("");
      }

	  if(parseInt($(':radio[name=Channel]:checked').val())!=4){
		  if (iscode_2 != 1) {
			  $("#code_msg").html("请先获取验证码！");
			  return;
		  } else {
			  $("#code_msg").html("");
		  }
	  }

      if(pwdtype!=3){
          if (pwd == "") {
              $("#pwd_msg").removeClass().addClass("passswordfr").html("请设置新密码！");
              $("v_pwd").focus();
              return;
          } else if (pwd.PWD() == false) {
              $("#pwd_msg").removeClass().addClass("passswordfr").html("请输入6～15位的密码！");
              return;
          } else if (pwd.length > 15) {
              $("#pwd_msg").removeClass().addClass("passswordfr").html("请输入6～15位的密码！");
              return;
          } else {
              $("#pwd_msg").removeClass().addClass("passswordfr_ts").html("由字母、数字组成，长度6－15个字符");
          }
          
          if (pwd1 == "") {
              $("#pwd_msg1").html("请设置新密码！");
              $("#v_pwd1").focus();
              return;
          } else if (pwd != pwd1) {
              $("#pwd_msg1").html("两次输入密码不匹配！");
              $("#v_pwd1").focus();
              return;
          } else {
              $("#pwd_msg1").html("");
          }
      }

      index=3;
  }

  $.ajax({
      dataType: "json",
      type: "POST",
      data: {'phone': phone1, 'code': code, 'pwd': pwd,'pwd1': pwd1, 'flag': flag,'pwdtype':pwdtype},
      cache: false,
      url: "/forgetpassword_ajax.php",
      error: function () {
          alert("错误")
      },
      success: function (data) {

          if (data.status == 0) {
                  $('#modeldiv').html(data.content);
				  $("#v_phone").html(data.phone);
                  $("#userid").val(data.userid);
                  $('.doc_password').css("display", "none");
                  $('.doc_password').eq(index).css("display", "");
                  if(data.pwdtype!=3&&flag==1){
                        $("#setsdiv").show();
                  }
                  if(data.pwdtype==3&&flag==2){
                        $("#finishtip").html("您的得胜28帐号为:<font color='red'>"+data.msg+"</font>");
                  }

          } else {
			  message = decodeURIComponent(data.msg);
			  if(data.status=="111"){
			  	alert(message);
				location.href=location.href;
			  }else{
              	$.jBox(message,{title: '',width: 460,height: 185,buttons: {}});
			  }
          }
      }
  });
}
var cc;
function sendcode() {
 
     $("#code_btn").attr("disabled",true);
	 channel = $(":radio[name=Channel]:checked").val();
     $.ajax({
          dataType: "json",
          type: "POST",
          data: {'flag': 9,'channel':channel},
          cache: false,
          url: "/forgetpassword_ajax.php",
          error: function () {
              alert("错误")
          },
          success: function (data) {
              if (data.status == 0) {
                  iscode_2 = 1;
				  EndTime=120;
                  cc = setInterval("GetRTime()", 1000);    //倒计时

                  message = decodeURIComponent("验证码发送成功！");

              } else {
                  
                $("#code_btn").attr("disabled",false);
                message = decodeURIComponent(data.msg);
              }
              $.jBox(message,{title: '提醒',width: 460,height: 185,buttons: {}});
          }
      });
}



var EndTime = 120;
function GetRTime() {
	
  //var mini = Math.floor(EndTime / 60);
  //var sec = Math.floor(EndTime % 60);
  if (EndTime >= 0) {
      $("#code_msg").html(EndTime+"秒可以重新发送");  
  }else {
       $("#code_btn").attr("disabled",false);
      $("#code_msg").html("");
      return;
  }
  EndTime --;
}



$(":radio[name=Channel]").live("change",function(){	
	if($(this).val()==4){
		url = "/wx/pwdewm.php?_"+(new Date()).getMilliseconds();
		$('#yzewm').attr("src",url);
		$('#ewmdiv').show();
		$('#code_btn').hide();
		
	}else{
		$('#ewmdiv').hide();
		$('#code_btn').show();
		
	}	
})


